package cn.openea.perpartner.cms.web.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.openea.perpartner.cms.web.dto.QrCodeDto;
import cn.openea.perpartner.cms.web.dto.SyncDto;
import cn.openea.perpartner.cms.web.service.ICmsQrCodeService;
import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Weird077
 * @description TODO
 * @date 2022-09-13 17:42
 */
@Api(tags = "二维码")
@Controller
@RequestMapping("qr")
public class CmsQrCodeController extends BaseController {
    @Autowired
    private ICmsQrCodeService codeService;

    @ApiOperation("销售二维码")
    @PostMapping("/sales")
    @ResponseBody
    public JSONObject createSalesCode(@RequestBody QrCodeDto codeDto) {
        return codeService.createSalesCode(codeDto);
    }

    @ApiOperation("助理二维码")
    @PostMapping("/assistant")
    @ResponseBody
    public JSONObject createSalesAssistantCode(@RequestBody QrCodeDto codeDto) {
        return codeService.createSalesAssistantCode(codeDto);
    }

    @ApiOperation("商家二维码")
    @PostMapping("/customer")
    @ResponseBody
    public JSONObject createCustomerCode(@RequestBody QrCodeDto codeDto) {
        return codeService.createCustomerCode(codeDto);
    }
    @ApiOperation("团长二维码")
    @PostMapping("/community")
    @ResponseBody
    public JSONObject createCommunityCode(@RequestBody QrCodeDto codeDto) {
        return codeService.createCommunityCode(codeDto);
    }

    @ApiOperation("回调二维码")
    @PostMapping("/sync")
    @ResponseBody
    public AjaxResult sync(@RequestBody SyncDto syncDto) {

        return success(codeService.sync(syncDto));
    }
}
